package interviewpreparationkit.array

import org.junit.jupiter.api.Test
import java.util.*
import kotlin.test.assertEquals

class ArrayManipulationTests {
    @Test
    fun arrayManipulationTest() {
        val scan = Scanner(ArrayManipulationTests::class.java.getResourceAsStream("/arrayManipulation.txt"))
        while (scan.hasNextLine()) {
            val nm = scan.nextLine().split(" ")

            val n = nm[0].trim().toInt()

            val m = nm[1].trim().toInt()

            val queries = Array<Array<Int>>(m, { Array<Int>(3, { 0 }) })

            for (i in 0 until m) {
                queries[i] = scan.nextLine().split(" ").map { it.trim().toInt() }.toTypedArray()
            }

            val result = arrayManipulation(n, queries)

            println(result)
            assertEquals(scan.nextLine().trim().toLong(), result)
        }
    }
}